/*************************************************
 * File name: main.c
 * Description: 唯一入口，负责加载数据并启动主菜单
 *************************************************/
#include "sport_type.h"
#include "sport_data.h"
#include "sport_ui.h"
#include <stdlib.h>

int main(void)
{
    ProjectList proj_head = NULL;
    PlayerList  play_head = NULL;
    int         serial_counter = 0;

    /* 加载历史数据 */
    proj_head = Project_LoadFromFile(PROJECT_FILE_NAME);
    play_head = Player_LoadFromFile(PLAYER_FILE_NAME, &serial_counter);

    /* 进入主循环 */
    UI_MainMenu(&proj_head, &play_head, &serial_counter);

    /* 保存并清理 */
    (void)Project_SaveToFile(proj_head, PROJECT_FILE_NAME);
    (void)Player_SaveToFile(play_head, serial_counter, PLAYER_FILE_NAME);

    return 0; 
}